using namespace std;

#include <string>

#include "sequence.h"
#include "node_element.h"

Sequence::Sequence () {
}

Sequence::~Sequence () {
}

string Sequence::generateRegex(DoctypeDefinition* dtd) {
	string regex = "(";
	
	for (list<BaseSubElement*>::iterator iter=(children.begin());
		 iter!=(children.end());
		 iter++) {
		
		regex += (*iter)->generateRegex(dtd);
	}
	
	regex += "){"+NodeElement::intToString((unsigned int) multiplicity->min);
	regex += ","+NodeElement::intToString((unsigned int) multiplicity->max)+"}";
	
	return regex;
}

void Sequence::print(std::ostream& out) {
	out << "(";
	list<BaseSubElement*>::iterator it = children.begin();
	while (it != children.end()) {
    	(*it)->print(out);
    	if (++it != children.end()) {
    		out << ", ";
    	}
    }
    out << ")";
	multiplicity->print(out);
}
